﻿using DataModels.Dto;
using DataModels.Dto.WorkOrder;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Services.WorkOrder;
using Utils;
using static DataModels.Enums.GeneralEnum;

namespace PropertyManagementWebApi.Controllers.WorkOrder
{
    public class WorkOrderRapidController(WorkOrderRapidService workOrderService) : BaseController
    {
        protected readonly WorkOrderRapidService _workOrderService = workOrderService;

        /// <summary>
        /// 获取工单类型 jihekuaisu
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ResponseModel GetWorkOrderType(int parentId = -1)
        {
            return _workOrderService.GetWorkOrderType(parentId);
        }
        /// <summary>
        /// 通过项目获取物料类型
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ResponseModel GetMaterialByProjectUUID(string  ProjectUUID)
        {
          return _workOrderService.GetMaterialByProjectUUID(ProjectUUID);
        }
        /// <summary>
        /// 提交快速工单
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ResponseModel> CreateRapidWorkOrder(CreateWorkOrderInfo info)
        {
            return _workOrderService.CreateRapidWorkOrder(info);
        }

        /// <summary>
        /// 更新快速工单状态 （1.已分配 2处理中 3等待用户反馈 4已解决）
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPost]
        public ResponseModel UpdateRapidWorkOrderStatus(CancelledWorkOrderRapid info)
        {
            return _workOrderService.UpdateRapidWorkOrderRapidStatus(info);
        }

        /// <summary>
        /// 取消工单
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPost]
        public ResponseModel CancelledWorkOrder(CancelledWorkOrder info)
        {
            return _workOrderService.CancelledWorkOrder(info);
        }

        /// <summary>
        /// 催工单
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPost]
        public ResponseModel UrgentWorkOrder(UrgentWorkOrder info)
        {
            return _workOrderService.UrgentWorkOrder(info);
        }

        /// <summary>
        /// 评价工单
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPost]
        public ResponseModel ResolvedWorkOrder(ResolvedWorkOrder info)
        {
            return _workOrderService.ResolvedWorkOrder(info);
        }

        /// <summary>
        /// 获取快速工单列表
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpGet]
        public ResponseModel GetWorkOrder([FromQuery] GetWorkOrderRapidInfo info)
        {
            return _workOrderService.GetWorkOrder(info);
        }

        /// <summary>
        /// 获取工单详情历史记录
        /// </summary>
        /// <param name="WorkOrderId"></param>
        /// <returns></returns>
        [HttpGet]
        public ResponseModel GetWorkOrderHistory([GeneralRequired] Guid WorkOrderId)
        {
            return _workOrderService.GetWorkOrderHistory(WorkOrderId);
        }
    }
}
